package com.googlecode.pdfbricks.engine.to;

/**
 * @author Johny Huang
 * @date 2009-3-12
 */
public class PageRange implements Comparable {
	private int startIndex = 0;
	private int endIndex = 0;

	public void setSinglePage(final int pageIndex) {
		startIndex = pageIndex;
		endIndex = pageIndex;
	}

	public int getStartIndex() {
		return startIndex;
	}

	public void setStartIndex(final int startIndex) {
		this.startIndex = startIndex;
	}

	public int getEndIndex() {
		return endIndex;
	}

	public void setEndIndex(final int endIndex) {
		this.endIndex = endIndex;
	}

	public int compareTo(Object obj) {
		PageRange pageRange=(PageRange)obj;
		int result=this.startIndex-pageRange.getStartIndex();
		if(result==0){
			result=this.endIndex-pageRange.getEndIndex();
		}
		return result; 	
	}
	
	public boolean equals(final Object obj){
		boolean result=false;
		if(obj instanceof PageRange){
			PageRange pr=(PageRange)obj;
			result=this.startIndex==pr.getStartIndex()&&this.endIndex==pr.getEndIndex();
		}
		return result;
	}
	
	public int hashCode(){
		int result=startIndex*25+endIndex;
		return result;
	}
}
